import { DataSourceJsonData } from '@grafana/data';
import { DataQuery } from '@grafana/schema';

export type ResultFormat = 'time_series' | 'table' | 'logs';

export interface MyQuery extends DataQuery {
  queryText?: string;
  constant: number;

  query: string;
  alias?: string;

  resultFormat?: ResultFormat;

  obsQueryType?: OBSQueryType

  rawQuery: boolean
}

export const DEFAULT_QUERY: Partial<MyQuery> = {
  constant: 6.5,
};

export interface DataPoint {
  Time: number;
  Value: number;
}

export interface DataSourceResponse {
  datapoints: DataPoint[];
}

/**
 * These are options configured for each DataSource instance
 */
export interface MyDataSourceOptions extends DataSourceJsonData {
  path?: string;

  channel?: QueryChannel;

  // OBS
  bucket: string;
  endpoint: string;

  // GeminiDB Influx
  url: string; // http

  user: string;
  database: string;
}

/**
 * Value that is used in the backend, but never sent over HTTP to the frontend
 */
export interface MySecureJsonData {
  apiKey?: string;
  secretKey?: string;

  password?: string
}

export enum QueryChannel {
  Direct = 'Direct',
  Influx = 'Influx',
}

export enum OBSQueryType {
  Buckets = 1, // bucket list
  Storage = 2, // Storage
  Cost = 3 // cost fee
}
